package org.cdivtc.exam.entity;

import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result<T> {
    @ApiModelProperty(value = "状态码", example = "200")
    private Integer code;
    @ApiModelProperty(value = "返回消息", example = "操作成功")
    private String message;
    @ApiModelProperty("返回数据")
    private T data;

    public static <T> Result<T> success() {
        return new Result<>(200, "成功", null);
    }

    public static <T> Result<T> success(T data) {
        return new Result<>(200, "成功", data);
    }

    public static <T> Result<T> error(String message) {
        return new Result<>(400, message, null);
    }
}